﻿using System.Collections.Generic;
using System.Collections.Specialized;

namespace System.Modules.Contracts.DTO
{
    /// <summary>
    /// Email Activity
    /// </summary>
    [Serializable]
    public class EmailActivity
    {
        #region Constructors
        /// <summary>
        /// Default Constructor
        /// </summary>
        public EmailActivity()
        {
            To = new List<string>();
            CC = new List<string>();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        public EmailActivity(string to, string subject, string body) : this(to, string.Empty, subject, body) { }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        public EmailActivity(List<string> to, string subject, string body) : this(to, new List<string>(), subject, body) { }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="to"></param>
        /// <param name="cc"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        public EmailActivity(List<string> to, List<string> cc, string subject, string body)
        {
            To = to;
            CC = cc;
            Subject = subject;
            Body = body;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="to"></param>
        /// <param name="cc"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        public EmailActivity(string to, string cc, string subject, string body) : this()
        {
            To.Add(to);
            CC.Add(cc);
            Subject = subject;
            Body = body;
        }
        #endregion

        #region Public Properties
        /// <summary>
        /// Subject | string
        /// </summary>
        public string Subject { get; set; }
        /// <summary>
        /// Body | string
        /// </summary>
        public string Body { get; set; }
        /// <summary>
        /// To | List of string
        /// </summary>
        public List<string> To { get; set; }
        /// <summary>
        /// CC | List of string
        /// </summary>
        public List<string> CC { get; set; }
        /// <summary>
        /// Header | string Dictionary
        /// </summary>
        public StringDictionary Header
        {
            get
            {
                var header = new StringDictionary();
                if (To.Count > 0)
                {
                    header.Add("to", string.Join(",", To.ToArray()));
                }
                if (CC.Count > 0)
                {
                    header.Add("cc", string.Join(",", To.ToArray()));
                }
                if (!string.IsNullOrEmpty(Subject))
                {
                    header.Add("subject", Subject);
                }

                return header;
            }
        }
        #endregion
    }
}
